﻿@using UCosmic.Www.Mvc
@using UCosmic.Www.Mvc.Areas.Establishments.Models.ManagementForms
@model EstablishmentForm.EstablishmentNameForm
@{
    if (Html.ViewContext.FormContext == null)
    { // make sure unobtrusive data-val attributes appear in form elements
        Html.ViewContext.FormContext = new FormContext();
    }
}
<li class="allowed-type appender">
    @using (Html.BeginCollectionItem("Names"))
    {
        var addingDisplay = (!Model.IsAdded) ? "display:none;" : string.Empty;
        var editingDisplay = (Model.IsAdded) ? "display:none;" : string.Empty;
        const string currentName = "Current Name";
        const string formerName = "Former Name";
        const string languageUnknown = "Language Unknown";
        <div class="editor" style="@editingDisplay">
            <div class ="value" style="@addingDisplay margin-bottom: 1em;">
                <div>
                    <div>@Html.LabelFor(m => m.Text)
                    </div>
                    <div>@Html.TextAreaFor(m => m.Text, new { rows = 2 })
                    </div>
                    <div class="validate">
                        @Html.ValidationMessageFor(m => m.Text)
                    </div>
                </div>
                <div style="height: 1em">
                </div>
                <div>
                    <div>@Html.LabelFor(m => m.TranslationToLanguage)
                    </div>
                    <div>@Html.DropDownListFor(m => m.TranslationToLanguage.RevisionId, Model.TranslationToLanguage.Options,
                        ModelMetadata.FromLambdaExpression(m => m.TranslationToLanguage, ViewData).NullDisplayText)
                        @Html.ValidationMessageFor(m => m.TranslationToLanguage.RevisionId)
                    </div>
                </div>
                <div style="height: 1em">
                </div>
                <input type="hidden" class="htext" value="@Model.Text" />
                <br />
                @Html.RadioButtonFor(model => model.IsFormerName, false,
                new { id = string.Format("{0}_{1}", Html.IdFor(m => m.IsFormerName), "current") })
                <label for="@string.Format("{0}_{1}", Html.IdFor(m => m.IsFormerName), "current")">
                    This is a current name.</label>
                <br />
                @Html.RadioButtonFor(model => model.IsFormerName, true, new { id = string.Format("{0}_{1}", Html.IdFor(m => m.IsFormerName), "former") })
                <label for="@string.Format("{0}_{1}", Html.IdFor(m => m.IsFormerName), "former")">
                    This is a previous/former name.</label>
                <br />
                <input type="hidden" class="hlangtext" value="@Html.DisplayFor(m => m.TranslationToLanguage.TranslatedNameText)" />
            </div>
            <div class="actions" style="padding-left: 3px;">
                <span class="add"><a href="#">Add</a></span> <span class="edit" style="@addingDisplay">
                    <a href="#">Save</a></span> <span class="cancel" style="@addingDisplay">| <a href="#">
                        Cancel</a></span>
            </div>
        </div>
        <div class="reader" style="@addingDisplay">
            <div class="value mimic-textbox">
                <span class="text">@Model.Text</span>
                <br />
                <span class="lang" style="font-size: 0.75em;">
                    @if (Model.TranslationToLanguage != null)
                    {
                        <span>@Html.DisplayFor(m => m.TranslationToLanguage.TranslatedNameText)</span>
                    }
                    else
                    {
                        <span>@languageUnknown</span>
                    }
                </span>, <span class="formerorcurrent" style="font-size: 0.75em;">
                    @(@Model.IsFormerName ? formerName : currentName)
                </span>
            </div>
            <div class="actions" style="padding-left: 3px;">
                <span class="edit"><a href="#">Edit</a></span> | <span class="remove"><a href="#">Remove</a></span>
            </div>
        </div>
        <div class="hidden-input">
            @Html.EditorFor(m => m.RevisionId)
            @Html.EditorFor(m => m.ForEstablishmentRevisionId)
            <span class="is-added">
                @Html.EditorFor(m => m.IsAdded)
            </span>
            @Html.EditorFor(m => m.TranslationToLanguage)        </div>
    }
</li>
